package com.shms.service.impl;

import java.util.List;

import com.shms.bean.GroupOfBuilds;
import com.shms.service.ShBuildService;
import com.shms.dao.ShBuildDao;
import com.shms.entity.ShBuild;
public class ShBuildsServiceImpl implements  ShBuildService{
	private ShBuildDao shBuildDao;
	
	@Override
	public GroupOfBuilds queryBuilds(GroupOfBuilds groupOfBuilds) {
		if (groupOfBuilds.getType().equals("forward")) {
			int currentPage = groupOfBuilds.getCurrentPage() - 2;
			groupOfBuilds.setCurrentPage(currentPage);
		}
		return shBuildDao.queryBuilds(groupOfBuilds);
	}
	
	public List<ShBuild> queryAllBno(){
		return shBuildDao.getAllBno();
	}
	
	@Override
	public boolean batchDelete(Integer[] nos){
		return this.shBuildDao.batchDelete(nos);
	}
	
	@Override
	public boolean saveBuilds(ShBuild shBuild) {
		boolean rtn = true;
		if (shBuild.getBid() == 0) {
			rtn = shBuildDao.saveBuilds(shBuild);
		} else {
			rtn = shBuildDao.updateBuilds(shBuild);
		}
		return rtn;
	}
	
	@Override
	public ShBuild queryById(ShBuild shBuild) {
		return shBuildDao.queryById(shBuild);
	}
	
	public String queryBnameByBid(String bid){
		return shBuildDao.queryBnameByBid(bid);
	}
	
	public void setShBuildDao(ShBuildDao shBuildDao) {
		this.shBuildDao = shBuildDao;
	}

	@Override
	public boolean queryBuildsById(ShBuild shBuild) {
		return this.shBuildDao.queryBuildsById(shBuild);
	}
}
